<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
	</head>
	<body>
		<div id="app">
			<wrapper></wrapper>
		</div>
		
		<script>
			var app = Vue.createApp({
				data(){
					return {
						message:"Hello World!",
					}
				}
			})
			
			// 注册一个全局组件
			app.component('counter',{
				data(){
					return {
						count: 0,
					}
				},
				template: "<button @click='count++'>{{count}}</button>"
			})
			
			app.component('wrapper',{
				data(){
					return {
						msg: "这是一个wrapper组件，是一个自定义组件",
						num: 0
					}
				},
				template: "<div>{{msg}}<br />{{num}}<button @click='add'>+</button><br /><counter></counter></div>",
				methods:{
					add(){
						this.num ++
					}
				}
			})
			
			var vm = app.mount("#app")
		</script>
	</body>
</html>
